<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>

<%

            boolean scoreSearch = request.getParameter("sType") != null && request.getParameter("sType").trim().equals("score");
            boolean scoreOrder = request.getParameter("sOrder") != null && request.getParameter("sOrder").trim().equals("score");

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Big<%=Util.getUtil().getBoard(request) == Util.BCB ? "College" : "Law"%>Board.com</title>
        <link rel="shortcut icon" href="ext/c_sailboat.gif">
        <link rel="stylesheet" type="text/css" href="ext/tlbStyle.css" />
        <script type="text/javascript" src="ext/tlbMenu.js" />
        <script type="text/javascript">
            window.onload = initLeftMenu;
        </script>
    </head>
    
    <body onload="initLeftMenu()">
        <center>
            <div id="mainContainer">
                
                <table>
                    <tr>
                        <td colspan=2>
                            <div id="topBar">
                                <%@ include file="header.jsp" %>
                                <br />
                            </div>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="top">
                            
                            <div id="contentContainer" style="background-color:#FFFFFF">
                                <h1>Discussion Forum</h1>
                                
                                <table border=0 cellpadding=0 cellspacing=0 width=500>
                                    
                                    
                                    <tr>
                                        <td colspan="3">
                                            <form action="index.jsp" name="searchForm" method="post">
                                                <input size=15 name="q" value="<%=request.getParameter("q") == null ? "" : request.getParameter("q").trim()%>" />
                                                <input type="submit" value="Search" class="btn" />
                                            </form>
                                            <br />
                                        </td>
                                    </tr>
                                    
                                    <%
            ThreadDAO t = new ThreadDAO();
            List list = null;
            if (request.getParameter("q") != null && request.getParameter("q").trim().length() > 2) {
                list = t.searchThreadsAdv((session.getAttribute("poster") == null ? 0 : ((Poster) session.getAttribute("poster")).getPosterId()), 150, request.getParameter("q").trim(), request.getParameter("startDate").trim(), request.getParameter("stopDate").trim(), scoreSearch, scoreOrder);
            }
            //searchThreadsAdv(int posterId, int topCount, String searchString, String startDate, String stopDate, boolean scoreSearchType, boolean scoreSearchOrder) {

            if (list != null) {
                for (Iterator it = list.iterator(); it.hasNext();) {
                    ThreadList thread = (ThreadList) it.next();

                    if (thread.getPower() != 0 && scoreSearch) {
                        thread.setTitle("[" + thread.getPower() + "] " + thread.getTitle());
                    }

                    thread.setTitle(new MonikerDAO().fixHTML(thread.getTitle()));

                    if (thread.getTitle() != null && thread.getTitle().length() > 35 && (thread.getTitle().indexOf(" ") == -1 || thread.getTitle().indexOf(" ") > 35)) {
                        thread.setTitle(thread.getTitle().substring(0, 35) + "<br>" + thread.getTitle().substring(35));
                    }

                                    %>
                                    <tr><td><a target="new<%=thread.getThreadId()%>" href='viewThread.jsp?threadId=<%=thread.getThreadId()%>&x=<%=thread.getThreadCount()%>'><%=thread.getTitle()%></a></td><td>&nbsp;&nbsp;&nbsp;<%=thread.getLastPostString()%></td><td>&nbsp;(<%=thread.getThreadCount()%>)</td></tr>
                                    <%
                                        }
                                    } else {
                                    %><br>No results for search: <%=request.getParameter("q")%><%
            }
                                    %>
                                    
                                    
                                </TABLE>
                            </div>
                        </td>
                        <td valign=top>
                            
                            <%@ include file="menu.jsp" %>
                            
                        </td>
                    </tr>
                </table>
                
                
            </div>
            <!-- Start of StatCounter Code -->
            <script type="text/javascript">
                var sc_project=2753481; 
                var sc_invisible=0; 
                var sc_partition=27; 
                var sc_security="fadeb289"; 
            </script>
            <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c28.statcounter.com/2753481/0/fadeb289/0/" alt="blog stats" /></a></div></noscript>
            <!-- End of StatCounter Code -->
        </center>
    </body>
</html>